Rotating the Curve
The third supporting object referenced by your curve shape object is its transform object. The properties of the transform object allow you to specify how to map your shape (for example, move, scale, skew, and rotate).QuickDraw GX provides a number of functions to make it easy to map your shape. One example is the
GXRotateShape
function. This function takes these parameters:
Suppose you want to rotate your curve shape around its center. You can use
- a reference to the shape to rotate
- the number of degrees to rotate the shape
- an x-coordinate and a y-coordinate indicating the origin around which you want to rotate the shape.
theGXGetShapeCenter
function to find the coordinates that best describe the center of the shape. This function is one of many geometric operations provided by QuickDraw GX.To find the center of your curve shape, you need to define a point structure to contain the calculated center and then call the
GXGetShapeCenter
function
to calculate the center point:
gxPoint curveCenter; GXGetShapeCenter(aCurveShape, 0, &curveCenter);TheGXGetShapeCenter
function analyzes the geometry of your curve shape, finds the best center point, and returns the coordinates of the center point
in thecurveCenter
point structure. (The second parameter specifies which contour you want to find the center of--not very useful in this case, because a curve shape has only one contour. You can use a value of 0 for this parameter to indicate that you want to find the center of the entire shape.)Once you have found the shape's center, you can rotate the shape around its center using the
GXRotateShape
function:
GXRotateShape(aCurveShape, ff(45), curveCenter.x, curveCenter.y);This call to theGXRotateShape
function rotates your curve clockwise
45.0 degrees around its center.
- Note
- The
GXRotateShape
function can rotate a shape in one
of two ways: by changing the mapping property of the shape's transform object or by changing the geometric points stored in the shape's geometry property. To use
the first method, you must set the map transform shape attribute, which is a flag in the shape attributes property
of your curve shape. You can set this attribute using theGXSetShapeAttributes
function. See "Editing Shape Transforms" in Chapter 6, "Handling Graphics,"
for details.![]()